<template is="msgItem1">
	<view class="content">
		
		<view class="upload-example">
			<view class="title">{{hb.desc}}</view>
			<img :src="url + hb.pic">
		</view>
		
		<view class="already">已领{{hb.r_num}}/{{hb.num}}个，剩余{{num}}个/{{hb.surplus}}元</view>
		
		<view class="gotophoto" @click="gotolin"><img src="/static/paizhao.png"><view class="title">拍照领红包</view></view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// number_min:"1",
				// number_max:"10",
				// money_min:"9",
				// money_max:"30.53",
				hb:"",
				num:"",
				id:"",
				token:"",
				url:"",
				
				lingqu:""
			}
		},
		onShow() {
			
		},
		onLoad(options) {
			var _self = this
			_self.id = options.id
			console.log(options)
			_self.url = _self.$url
			const value = uni.getStorageSync('userinfo');
			
			if (value) {
				_self.userinfo = value
				_self.token = value.token
				uni.request({
				    url: _self.$url + '/api/lucky_money/luckyMoneyDetail', 
					method:"post",
				    data: {
				       id:_self.id
				    },
					header: {
						'token': _self.token 
					},
				    success: (res) => {
						_self.hb = res.data.result.data
						_self.num = _self.hb.num - _self.hb.r_num
						_self.lingqu = res.data.result.data.r_status
				    }
				});
			}else{
				uni.navigateTo({
				  url: '/pages/index/authorization',
				  animationType: 'pop-in',
				  animationDuration: 200
				});
			}
			
		},
		methods: {
			gotolin(){
				var _self = this
				if(_self.r_status == 0){
					uni.checkSession({
						success () {
							uni.navigateTo({
								url: '/pages/index/receive_red?id=' + _self.id,
								animationType: 'pop-in',
								animationDuration: 200
							});
						},
						fail () {
						  uni.navigateTo({
							  url: '/pages/index/authorization',
							  animationType: 'pop-in',
							  animationDuration: 200
						  });
						}
					})
				}else{
					uni.navigateTo({
					  url: '/pages/index/receive',
					  animationType: 'pop-in',
					  animationDuration: 200
					});
				}
				
				
			}
		}
	}
</script>

<style lang="scss">
	body{
		background: #F3F3F3;
		font-size: 14px;
	}
	view{
		box-sizing: border-box;
	}
	.upload-example{
		width: 90%;
		box-sizing: border-box;
		margin:50rpx auto;
		background: #fff;
		border-radius: 5px;
		display: flex;
		flex-direction: column;
		align-items: center;
		.title{
			margin:40rpx 0 40rpx 0;
			font-size: 16px;
		}
		img{
			width: 400rpx;
			height: 400rpx;
			margin-bottom:40rpx;
		}
	}
	.already{
		width: 100%;
		margin:40rpx 0;
		text-align: center;
	}
	.gotophoto{
		width: 90%;
		margin: 0 auto;
		background: #F4313E;
		text-align: center;
		border-radius: 5px;
		color: #fff;
		padding:20rpx 0;
		display: flex;
		flex-direction: row;
		justify-content: center;
		align-items: center;
		.title{
			
		}
		img{
			width: 50rpx;
			height: 50rpx;
			margin-right:20rpx;
		}
	}
</style>
